package cn.cvs.controller;

import cn.cvs.pojo.Supplier;
import cn.cvs.pojo.SysRole;
import cn.cvs.service.SupplierService;
import cn.cvs.service.SysRoleService;
import cn.cvs.utils.Constants;
import cn.cvs.utils.PageSupport;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/role")
public class SysRoleController {
    private Logger logger = Logger.getLogger(SupplierController.class);
    @Resource

    private SysRoleService sysRoleService;

    @GetMapping("/list")
    public String getsysRoleList(Model model){
        List<SysRole> roleList = new ArrayList<>();
        try{
            roleList = sysRoleService.getRoleList();
            model.addAttribute("roleList",roleList);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("SysUserController->getSupplierList: 供货商列表接口访问失败!");
            return "redirect:/toSysError";
        }
        return "sysRole/list";
    }

    // 跳转到异常处理页面
    @RequestMapping(value = "/toSysError")
    public String sysError(){
        return "sysError";
    }
}
